using QxFramework.Core;
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
using UnityEngine.UI;

public class ShopMenu : UIBase
{
    public ShopCell _shopCell;

    private Button closeBtn;
    private ICameraManager _iCamerManager;
    private BagManager _bagManager;
    public override void OnDisplay(object args)
    {
        base.OnDisplay(args);
        transform.localPosition = Vector3.zero;
        _iCamerManager = GameMgr.Get<ICameraManager>();

        _bagManager = GameObject.Find("BagMgr").GetComponent<BagManager>();
        _bagManager.CreatNextShop();

        closeBtn = transform.Find("CloseBtn").GetComponent<Button>();
        closeBtn.onClick.AddListener(CloseShopMenu);

        RefreshAllCell();
    }
    public void RefreshAllCell()
    {
        for (int i = 0; i < 6; i++)
        {
            _shopCell = transform.Find("Cells/Cell" + i.ToString()).GetComponent<ShopCell>();
            _shopCell.Item = _bagManager.Shop[i];
            _shopCell.RefreshSprite();
        }
    }

    public void CloseShopMenu()
    {
        StageInfo.Instance.RefreshLevel(false);
        UIManager.Instance.Close(this);
        _iCamerManager.isLocked(true);
    }
}
